#ifndef __pika_hal_mobile_h__
#define __pika_hal_mobile_h__

#include "PikaObj.h"

typedef enum{
    _PIKA_HAL_SIM_STATUS_UNUSED = 0,
    PIKA_HAL_MOBILE_SIM_READY,	/**< SIM卡已准备好*/
	PIKA_HAL_MOBILE_NO_SIM,			/**< 无SIM卡*/
	PIKA_HAL_MOBILE_SIM_NEED_PIN,	/**< 需要输入PIN码*/
}PIKA_HAL_MOBILE_SIM_STATUS;

typedef enum{
    _PIKA_HAL_REGISTER_STATUS_UNUSED = 0,
    PIKA_HAL_MOBILE_UNREGISTER,  /**< 网络未注册*/
	PIKA_HAL_MOBILE_REGISTERED,  /**< 网络已注册*/
	PIKA_HAL_MOBILE_SEARCHING,  	/**< 网络搜索中*/
	PIKA_HAL_MOBILE_REGISTER_DENIED,  	/**< 网络注册被拒绝*/
	PIKA_HAL_MOBILE_STATUS_UNKNOW,		/**< 网络状态未知*/
	PIKA_HAL_MOBILE_REGISTERED_ROAMING, 	/**< 网络已注册，漫游*/
	PIKA_HAL_MOBILE_SMS_ONLY_REGISTERED,
	PIKA_HAL_MOBILE_SMS_ONLY_REGISTERED_ROAMING,
	PIKA_HAL_MOBILE_EMERGENCY_REGISTERED,
	PIKA_HAL_MOBILE_CSFB_NOT_PREFERRED_REGISTERED,
	PIKA_HAL_MOBILE_CSFB_NOT_PREFERRED_REGISTERED_ROAMING,
}PIKA_HAL_MOBILE_REGISTER_STATUS;

typedef enum{
    _PIKA_HAL_MOBILE_NETWORK_UNUSED = 0,
	PIKA_HAL_MOBILE_NETWORK_UNKNOWN = 1,
	PIKA_HAL_MOBILE_NETWORK_GSM = 2,
	PIKA_HAL_MOBILE_NETWORK_LTE = 4,
}PIKA_HAL_MOBILE_NETWORK_TYPE;

#define PIKA_HAL_MOBILE_CELL_MAX_NUM 21

typedef struct pika_hal_mobile_gsm_service_cell_info
{
    int cid;        /**< Cell ID, (0 indicates information is not represent).*/
    int mcc;        /**< This field should be ignored when cid is not present*/
    int mnc;        /**< This field should be ignored when cid is not present*/
    int lac;        /**< Location area code.(This field should be ignord when cid is not present). */
    int arfcn;      /**< Absolute RF channel number. */
    int bsic;       /**< Base station identity code. (0 indicates information is not present). */
	int rssi;		/**< Receive signal strength, Value range: rxlev-111 for dbm format */
}pika_hal_mobile_gsm_service_cell_info;


typedef struct pika_hal_mobile_gsm_neighbor_cell_info
{
    int cid;        /**Cell ID, (0 indicates information is not represent).*/
    int mcc;        /**This field should be ignored when cid is not present*/
    int mnc;        /**This field should be ignored when cid is not present*/
    int lac;        /**Location area code.(This field should be ignord when cid is not present). */
    int arfcn;      /**Absolute RF channel number. */
    int bsic;       /**Base station identity code. (0 indicates information is not present). */
	int rssi;		/**< Receive signal strength, Value range: rxlev-111 for dbm format */
}pika_hal_mobile_gsm_neighbor_cell_info;

typedef struct pika_hal_mobile_gsm_cell_info{
	pika_hal_mobile_gsm_service_cell_info service_info;
	pika_hal_mobile_gsm_neighbor_cell_info neighbor_infos[PIKA_HAL_MOBILE_CELL_MAX_NUM];
	uint8_t neighbor_info_num; //邻小区信息数量
}pika_hal_mobile_gsm_cell_info;

typedef struct pika_hal_mobile_lte_service_cell_info
{
    uint32_t cid;           /**<Cell ID, (0 indicates information is not represent).*/
    uint16_t mcc;           /**This field should be ignored when cid is not present*/
    uint16_t mnc;           /**This field should be ignored when cid is not present*/
    uint16_t tac;           /**Tracing area code (This field should be ignored when cid is not present). */
    uint16_t pci;           /**Physical cell ID. Range: 0 to 503. */
    uint32_t earfcn;        /**E-UTRA absolute radio frequency channel number of the cell. RANGE: 0 TO 65535. */
    int16_t rssi;		   /**< Receive signal strength, Value range: rsrp-140 for dbm format */
	int16_t rsrp;
	int16_t rsrq;
	int16_t snr;
	uint8_t is_tdd;
	uint8_t band;
	uint8_t ulbandwidth;
	uint8_t dlbandwidth;
}pika_hal_mobile_lte_service_cell_info;


typedef struct pika_hal_mobile_lte_neighbor_cell_info
{
	uint32_t cid;           /**<Cell ID, (0 indicates information is not represent).*/
	uint16_t mcc;           /**This field should be ignored when cid is not present*/
	uint16_t mnc;           /**This field should be ignored when cid is not present*/
	uint16_t tac;           /**Tracing area code (This field should be ignored when cid is not present). */
	uint16_t pci;           /**Physical cell ID. Range: 0 to 503. */
	union
	{
		uint32_t earfcn;        /**E-UTRA absolute radio frequency channel number of the cell. RANGE: 0 TO 65535. */
		uint32_t frequency;
	};
    uint16_t bandwidth;
    uint16_t celltype; /*0:intra lte ncell, 1:inter lte ncell */
    int16_t rsrp;
	int16_t rsrq;
	int16_t snr;
	int16_t rssi;
}pika_hal_mobile_lte_neighbor_cell_info;

typedef struct pika_hal_mobile_lte_cell_info{
	pika_hal_mobile_lte_service_cell_info service_info;
	pika_hal_mobile_lte_neighbor_cell_info neighbor_infos[PIKA_HAL_MOBILE_CELL_MAX_NUM];
	uint8_t neighbor_info_num; //邻小区信息数量
}pika_hal_mobile_lte_cell_info;

typedef struct pika_hal_mobile_cell_info{
	PIKA_HAL_MOBILE_NETWORK_TYPE network_type;
	pika_hal_mobile_gsm_cell_info gsm_cell_info;
	pika_hal_mobile_lte_cell_info lte_cell_info;
}pika_hal_mobile_cell_info;

int pika_hal_mobile_get_imei(int sim_id, char* out, int maxlen);
int pika_hal_mobile_get_imsi(int sim_id, char* out, int maxlen);
int pika_hal_mobile_get_iccid(int sim_id, char* out, int maxlen);
int pika_hal_mobile_get_number(int sim_id, char* out, int maxlen);
int pika_hal_mobile_get_sim_id(void);
int pika_hal_mobile_get_sim_status(void);
void pika_hal_mobile_set_rrc_time(int sec);

int pika_hal_mobile_set_apn(int sim_id, int cid, char* apn_name, char * user_name, char* password, int ip_type, int protocol);
int pika_hal_mobile_active_apn(int sim_id, int cid, int enable);
int pika_hal_mobile_get_apn(int sim_id, int cid, char* apn_name, int maxlen);

int pika_hal_mobile_set_flymode(int sim_id, int enable);
int pika_hal_mobile_get_flymode(int sim_id);

void pika_hal_mobile_set_ipv6(int enable);
int pika_hal_mobile_get_ipv6(void);

void pika_hal_mobile_set_sync_time(int enable);
int pika_hal_mobile_get_sync_time(void);

int pika_hal_mobile_get_register_status(void);

int pika_hal_mobile_request_cell_info(int timeout);
int pika_hal_mobile_get_cell_info(pika_hal_mobile_cell_info* out);
int pika_hal_mobile_get_lte_cell_info(pika_hal_mobile_lte_cell_info * out);
int pika_hal_mobile_get_gsm_cell_info(pika_hal_mobile_gsm_cell_info * out);

int pika_hal_mobile_get_uplink_data_traffic(void);
int pika_hal_mobile_get_downlink_data_traffic(void);
int pika_hal_mobile_reset_uplink_data_traffic(void);
int pika_hal_mobile_reset_downlink_data_traffic(void);
int pika_hal_mobile_special_config(void);
int pika_hal_mobile_get_band(void);
int pika_hal_mobile_set_band(int band);
int pika_hal_mobile_reset_net(void);
int pika_hal_mobile_get_csq(int* out);
int pika_hal_mobile_get_rssi(int* out);

#endif

